<!--#include file="../nav/admin_top.php" -->

<?PHP $lmenuindex=1;?>
<!--#include file="../nav_menu/vege_begin.php" -->


 
<div class="menuBg">
	<a class="menuAdd" href="{url::build('admin_vege','add')}">添加菜品</a>
  <div style="clear:both"></div>
</div>
<div style="margin:10px auto">
	搜索：
	<select id="type_id" class="textBox">
		<option value="">-- 所有菜品类别 --</option>
		<?PHP
		foreach($rs as $v){ 
			echo '<option value="'.$v['id'].'">'.$v['type_name'].'</option>';
		}
		?> 
	</select>
	<select id="logo_id" class="textBox">
		<option value="">-- 所有菜品品牌 --</option>
		<?PHP
		foreach($logos as $v){ 
			echo '<option value="'.$v['id'].'">'.$v['logo_name'].'</option>';
		}
		?> 
	</select>
	
	<select id="sale" class="textBox">
		<option value="">-- 所有状态 --</option>
		<option value="1">当季供应</option>
		<option value="0">非当季供应</option>
		 
	</select>
   
	<input type="text" maxlength="12" id="keywords" class="searchs" /> 
	<input type="button"  onclick="fnSearchs()" value="查询"  />  	
</div> 
<div id="grids"></div> 
<script type="text/javascript">
var url_list = '/admin_vege/index_list'; 
var url_modify = '/admin_vege/modify'; 
var url_del = '/admin_vege/del'; 



$().ready(function(){
	o2js.build('ymprompt'); 
	o2js.build('o2grid');
	showLoading();
	grids = new o2Grid({
		bind:'grids', 
		url:url_list,
		singleSelect:true,
		imgpath:'/misc/vendors/o2js/o2grid/image',
		cols:[
			{index:'id',mapping:'a.id', name:'序号', width:40,sortable:false, func:function(val,row_index,column_name,json,R){
				 return  '<span title="ID：'+json.id+'" >'+((R.page - 1)*R.rowNum + (row_index+1))+'</span>';
			}}, 
			{index:'logo_name',mapping:'c.logo_name', name:'菜品品牌', width:80
			},
			{index:'type_name',mapping:'b.type_name', name:'菜品种类', width:80,func:function(val,row_index,column_name,json,R){
					return val;
				}
			},
			{index:'code',mapping:'a.code', name:'菜品编号', width:110,func:function(val,row_index,column_name,json,R){
					return val;
				}
			}, 
			{index:'name',mapping:'a.name', name:'菜品名称', width:110,func:function(val,row_index,column_name,json,R){
					return val;
				}
			}, 
			{index:'price',mapping:'a.price',align:'right', name:'菜品单价', width:70,func:function(val,row_index,column_name,json,R){
					return val+' 元';
				}
			},
			{index:'pack',mapping:'a.pack',align:'right', name:'包装规格', width:80,func:function(val,row_index,column_name,json,R){
					return val+' KG/份';
				}
			}, 
//			{index:'pic',mapping:'a.pic',align:'center', name:'缩率图', width:230,func:function(val,row_index,column_name,json,R){ 
//						if(val == ''){
//							return '';
//						}else{
//							return '<img height="90" width="120" src="'+baseUrl+val+'" />';
//						}
//				}
//			},
			{index:'sale',mapping:'a.sale', name:'状态', width:60,func:function(val,row_index,column_name,json,R){
					var s = '';
					if(val == '1'){ 
						s= '<span class="green">当季供应</span>';
					}else{
						s= '<span class="red">非当季供应</span>';
					}
					return s;
			}
			},
			{index:'id',mapping:'a.id', name:'操作'	, width:90,sortable:false,func:function(val,row_index,column_name,json,R){
					return    ' <a href="'+url_modify+'?id='+json.id+'" style="color: "  ><img src="/misc/images/edit.gif" />  编辑</a> ';
					// ' <a href="javascript:void(0)" onclick="fnDel('+json.id+')" ><img src="/misc/images/del.gif" /> 删除</a> ';
				}
			}
		],
		endfunc:function(obj){
			 
		}
	});
	fnSearchs();	 
	$('#keywords').keypress(function(e){
		if(e.keyCode==13||e.keyCode==10){
			fnSearchs();
		}
	}); 
	
});   
function fnSearchs(){
	grids.setBaseParams({
		keywords:encodeURIComponent($('#keywords').val()),
		type_id:$('#type_id').val(),
		logo_id:$('#logo_id').val(),
		sale:$('#sale').val()
	}); 
	grids.load(1); 
}
 

/* 删除 */
function fnDel(NId){
	fnConfirm({
		str:'确认删除本行数据?',
		func_true:function(){
			$('button').attr('disabled','disabled');
			$.post(
				url_del,
				{
					idarr:JSON.encode([NId])
				},
				function(e){
					var ok = errorHandler(e);
					if(ok && ok.success=='1'){
						//window.location.reload();
						grids.reload();
					}
					$('button').attr('disabled','');
				}
			);
		}
	}); 
}
</script>
<!--#include file="../nav_menu/vege_end.php" -->
<!--#include file="../nav/admin_bottom.php" -->